package com.daixin.blog.controller;

import com.daixin.blog.dto.PageinationDTO;
import com.daixin.blog.mapper.UserMapper;
import com.daixin.blog.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;

/**
 * Author daixin
 */
@Controller
public class QuestionController {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private QuestionService questionService;

    /***
     * 首页分页展示
     * @param request
     * @param model
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/question")
    public String question(HttpServletRequest request, Model model,
                        @RequestParam(value = "page",defaultValue = "1") Integer page,
                        @RequestParam(value = "size",defaultValue =  "8") Integer  size){
        //size 每页的个数

        PageinationDTO pageination = questionService.selectQuestion(page, size);
        model.addAttribute("pageinations", pageination);
        return "question";
    }
}
